<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增产品信息（下游/甲方）')" />
    <th:block th:include="include :: bootstrap-fileinput-css" />
    <th:block th:include="include :: select2-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-info-add">
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">产品名称：</label>
                <div class="col-sm-8">
                    <input name="productName" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">logo地址：</label>
                <div class="col-sm-8">
                    <img alt="[ 产品logo ]" width="90px" height="60px"  src="" id="logoUrl_img" th:src="*{logoUrl}">
                    <input name="logoUrl" id="logoUrl" class="form-control" type="hidden" required>
                    <input id="inputImage" name="file" type="file">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">产品描述：</label>
                <div class="col-sm-8">
                    <input name="descInfo" class="form-control" type="text" required>
                </div>
            </div>
<!--            <div class="form-group">-->
<!--                <label class="col-sm-3 control-label is-required">产品类型：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <input name="type" class="form-control" type="text" required>-->
<!--                </div>-->
<!--            </div>-->
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">产品详情地址：</label>
                <div class="col-sm-8">
                    <input name="detailUrl" class="form-control" type="text" required>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">申请人数：</label>
                <div class="col-sm-8">
                    <input name="applyNumber" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">产品标签：</label>
                <div class="col-sm-8">
                    <input name="productLabel" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">最大贷款额度：</label>
                <div class="col-sm-8">
                    <input name="maxLoanAmount" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">最小贷款额度：</label>
                <div class="col-sm-8">
                    <input name="minLoanAmount" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">贷款利率：</label>
                <div class="col-sm-8">
                    <input name="interestRate" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">最大贷款周期：</label>
                <div class="col-sm-8">
                    <input name="maxLoanPeriod" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">最小贷款周期：</label>
                <div class="col-sm-8">
                    <input name="minLoanPeriod" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">产品价格：</label>
                <div class="col-sm-8">
                    <input name="priceAmount" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">价格类型：</label>
                <div class="col-sm-8">
                    <select class="form-control"  name="priceType">
                        <option value="">所有</option>
                        <option th:each="item:${proPriceList}" th:value="${item.value}" th:text="${item.name}"></option>
                    </select>
                </div>
            </div>
<!--            <div class="form-group">-->
<!--                <label class="col-sm-3 control-label is-required">产品类型：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <select class="form-control"  name="type">-->
<!--                        <option value="">所有</option>-->
<!--                        <option th:each="item:${prodTypeList}" th:value="${item.value}" th:text="${item.name}"></option>-->
<!--                    </select>-->
<!--                </div>-->
<!--            </div>-->
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: bootstrap-fileinput-js" />
    <th:block th:include="include :: select2-js" />
    <script th:inline="javascript">
        var prefix = ctx + "product/info"
        $("#form-info-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-info-add').serialize());
            }
        }

        $(document).ready(function () {
            // 单图上传
            $("#inputImage").fileinput({
                uploadUrl: ctx + 'common/upload/product',
                maxFileCount: 1,
                autoReplace: true
            }).on('fileuploaded', function (event, data, previewId, index) {
                var rsp = data.response;
                // log.info("return url：" + rsp.url)
                // log.info("reutrn fileName：" + rsp.fileName)
                // log.info("reutrn newFileName：" + rsp.newFileName)
                // log.info("return originalFilename：" + rsp.originalFilename)
                $("#logoUrl").val(rsp.fileUrl)
                $("#logoUrl_img").attr("src", rsp.fileUrl)
            }).on('fileremoved', function (event, id, index) {
                $("input[name='" + event.currentTarget.id + "']").val('')
            })
        });
    </script>
</body>
</html>